'use strict';


const Controller = require('./base');

class FoodCategoryController extends Controller {

  async save(){
    const createRule = {
      categoryName: { type: 'string' },
      link: { type: 'string' },
    };
    // 校验参数
    this.ctx.validate(createRule);

    console.log(this.ctx.request.body, 'this.ctx.request.body');

    const member = Object.assign(this.ctx.request.body, {});

    await this.ctx.service.foodcategory.create(member);

    this.success();
  }

  async getAll(){
    const categories = await this.ctx.service.foodcategory.findAll();

    this.success(categories);
  }

}

module.exports = FoodCategoryController;
